#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QMutex>
#include "dispatcher.h"
#include <QQmlContext>
#include "shippool.h"
#include "cargopool.h"

void initContext(QQmlApplicationEngine& engine){
     engine.rootContext()->setContextProperty(QLatin1String("dispatcher"),
                                              Dispatcher::getInstance());
     engine.rootContext()->setContextProperty(QLatin1String("shipPool"),
                                              ShipPool::getInstance());
     engine.rootContext()->setContextProperty(QLatin1String("cargoPool"),
                                              CargoPool::getInstance());
}


int main(int argc, char *argv[])
{
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;
    initContext(engine);

    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    if (engine.rootObjects().isEmpty())
        return -1;

    return app.exec();
}
